package com.esunny.resourcevisualization.domain.response;

import com.esunny.resourcevisualization.util.ConstantUtil;

/**
 * @version 1.0.0.0
 * @ClassName ReturnStruct
 * @Description 后端响应给前端的返回数据结构
 * @Author baochencong
 * @Date 2020/9/30 8:26
 */
public class ReturnStructure {
    private int code;
    private String message;
    private Object data;

    public static ReturnStructure SUCCESS(String message, Object data) {
        return new ReturnStructure(ConstantUtil.HTTP_SUCCESS_CODE, message, data);
    }

    public static ReturnStructure ERROR(String message, Object data) {
        return new ReturnStructure(ConstantUtil.HTTP_FAILED_CODE, message, data);
    }

    public static ReturnStructure NOT_FOUND(String message, Object data) {
        return new ReturnStructure(ConstantUtil.HTTP_FAILED_CODE, message, data);
    }

    public static ReturnStructure NOT_FOUND() {
        return new ReturnStructure(ConstantUtil.HTTP_FAILED_CODE, "参数值为空", null);
    }

    public static ReturnStructure NOT_FOUND_APPLY() {
        return new ReturnStructure(ConstantUtil.HTTP_FAILED_CODE, "该申请不存在", null);
    }

    public ReturnStructure(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ReturnStructure(int code, String message) {
        this(code, message, null);
    }

    public ReturnStructure(int code) {
        this(code, null, null);
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
